<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">

    <title>JS+CSS实现日月交替效果</title>
    <link href="https://cdn.bootcdn.net/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <link rel="stylesheet" href="../css/37.css">
    <script>
        function change(str){
            document.getElementById('container').setAttribute('class',str);
        }
    </script>
</head>

<body>
    <div class="btn-box">
        <div onclick="change('light')">
            <i class="fa fa-sun-o" aria-hidden="true"></i> 你叉叉
        </div>
        <div onclick="change('dark')">
            <i class="fa fa-moon-o" aria-hidden="true"></i> 穷哈哈
        </div>
    </div>
    <div class="dark" id="container">
        <div class="bg"></div>
        <div class="moon-box">
            <div class="moon"></div>
        </div>
        <div class="sun-box">
            <div class="sun"></div>
        </div>
        <div class="sea"></div>
    </div>
</body>

</html>